<?php


namespace app\api\library\withdraw\currentWithdrawInfo;


use think\facade\Db;

class V
{
    public static function run($param)
    {
        
        $userId = _checkEmptyParam($param[ 'userId' ], '用户ID不能为空');
        $id     = _checkEmptyParam($param[ 'id' ], '提现方式ID不能为空');
        Db::startTrans();
        try {
            if (false === Db::name('mall_withdraw_info')->where('user_id', $userId)->update(['current' => 0])) {
                _outPut(204, '', '设置默认提现方式失败');
            }
            if (false === Db::name('mall_withdraw_info')->where('id', $id)->update(['current' => 1])) {
                _outPut(204, '', '设置默认提现方式失败');
            }
            Db::commit();
        } catch (\Exception $e) {
            Db::rollback();
            _outPut(201, $e->getMessage());
        }
        _outPut(200, '', '设置默认提现方式成功');
    }
}